<%--
  Created by IntelliJ IDEA.
  User: 金贤哲
  Date: 2017/5/16 0016
  Time: 14:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <meta charset="UTF-8">
    <script src="${ctxStatic}/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="${ctxStatic}/layer/layer.js"></script>
    <script src="http://api.map.baidu.com/api?v=2.0&ak=5RVK94VG4wr1KgfzG2ikW6vbLVAiieiY" type="text/javascript"></script>
    <style type="text/css">
        body, html,#allmap {width: 100%;height:100%;overflow: hidden;margin:0;}
    </style>
    <title>批量转换</title>
</head>
<body>
      <div id="ids" data-id="${ids}"></div>
      <div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
    $(document).ready(function() {
        //地图初始化
        var bm = new BMap.Map("allmap");
        bm.centerAndZoom(new BMap.Point(102.710087, 25.055138), 13);
        bm.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
        bm.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
        $('#ids').click(function () {
            var id=$(this).data("id");
            if ( id != '' ){
                $.ajax({
                    type: "POST",
                    url: "${ctx}/sys/gps/gps/getMaps",
                    data: {"id":id},
                    dataType: "json",
                    success: function(shu) {
                        if(shu == null ||shu.length == 0){
//                            alert("该客户无位置信息！");
                            layer.open({
                                type: 1 //Page层类型
                                ,area: ['300px', '200px']
                                ,title: '提示信息'
                                ,shade: 0.6 //遮罩透明度
                                ,anim: 2 //0-6的动画形式，-1不开启
                                ,content: '<div style="padding:50px;">该客户无足迹信息！</div>'
                            });
                        }
                        for(var i=0;i<shu.length;i++) {
                            var points = [new BMap.Point(shu[i].jd, shu[i].wd)
                            ];
                            var sc = [[shu[i].jd, shu[i].wd]];
                            console.log(sc);
                            //坐标转换完之后的回调函数
                            translateCallback = function (data) {
                                if (data.status === 0) {
                                    for (var i = 0; i < data.points.length; i++) {
                                        bm.addOverlay(new BMap.Marker(data.points[i]));
                                        bm.setCenter(data.points[i]);
                                    }
                                }
                            }
                            setTimeout(function () {
                                var convertor = new BMap.Convertor();
                                convertor.translate(points, 1, 5, translateCallback)
                            }, 1000);

                        }
                    }
                })
            }
        })
        $('#ids').trigger("click");
    })


</script>
